package com.sxj.corejava.code07_面向对象.继承;

/**
 * @author 石小俊
 * 2024年07月15日 16:24
 */
public class Pet {

    String name;
    int age;

    public void show() {
        System.out.println("这是父类的方法");
    }

    public Pet(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Pet() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

class Dog extends Pet {

    private String gender;
    String name;

    public void show() {
        System.out.println("这是子类的方法");
    }

    public void test() {
        System.out.println("name:" + name);
        System.out.println("父类name:" + super.name);
        this.show();
        super.show();
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Dog(String gender) {
        this.gender = gender;
    }

    public Dog() {
        super();
    }

    //public Dog(String name, int age) {
    //    super(name, age);
    //}
    //
    public Dog(String gender, String name, int age) {
        super(name, age);
        this.gender = gender;
    }

}

class TestPet {
    public static void main(String[] args) {
        Dog dog = new Dog("公", "宠物狗", 3);
        dog.name = "旺财";
        //dog.show();
        dog.test();
    }
}
